package com.china08.yxyapi.service.manage.tec.teaching.zujuan;

import java.util.List;

import org.elasticsearch.index.query.BoolQueryBuilder;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import com.china08.yxyapi.api.manage.tec.teaching.zujuan.previewpaper.ZujuanPaperGenerateController.DownLoadReqModel;
import com.china08.yxyapi.api.manage.tec.teaching.zujuan.previewpaper.ZujuanPaperSaveController.ReqModel;
import com.china08.yxyapi.entity.es.ElasticYxyYxyQuesResource;
import com.china08.yxyapi.security.profile.YxyProfile;

public interface ZujuanQuestionService {

    /**
     * 基础查询
     * 
     * @param boolQueryBuilder
     * @param level
     * @param type
     * @param srcType
     * @return
     */
    public BoolQueryBuilder get(BoolQueryBuilder boolQueryBuilder, String level, String type, String srcType);

    /**
     * 按照目录目录查询。 单纯目录
     * 
     * @param boolQueryBuilder
     * @param bookcontent
     * @return
     */
    public BoolQueryBuilder questionFindByBookcontent(BoolQueryBuilder boolQueryBuilder, String bookcontent);

    /**
     * 判断用户是否收藏了这个试题
     * 
     * @param userId
     * @param quesId
     * @return
     */
    public boolean checkCollectionQuestion(String userId, String quesId);

    /**
     * 查询我的收藏
     * 
     * @param userId
     * @param level
     * @param type
     * @return
     */
    public Page<ElasticYxyYxyQuesResource> collectionfindByMy(String phase, String subject, String userId, String level,
            String type, Pageable pageable);

    /**
     * 查询我的上传
     * 
     * @param phase
     * @param subject
     * @param userId
     * @param level
     * @param type
     * @param pageable
     * @return
     */
    public Page<ElasticYxyYxyQuesResource> findMyUpload(String phase, String subject, String userId, String level,
            String type, Pageable pageable);

    /**
     * 获取试题使用次数
     * 
     * @param quesId
     * @return
     */
    public Long countQuestionUse(String quesId);

    /***
     * 查询试题用时
     * 
     * @param quesId
     * @return
     */
    public double questionDateTime(String quesId);

    /**
     * 按目录查询
     * 
     * @param bookcontent
     * @param level
     * @param type
     * @param srcType
     * @param pageable
     * @return
     */
    public Page<ElasticYxyYxyQuesResource> questionFindByBookcontentAndLevelAndTypeAndUse(String bookcontent,
            String level, String type, String srcType, String userId, String bookId, Pageable pageable);

    /**
     * 按知识点，难度，类型，是否使用过（0 1）， 查询
     * 
     * @param know
     * @param level
     * @param type
     * @param srcType
     * @param pageable
     * @return
     */
    public Page<ElasticYxyYxyQuesResource> questionFindByKnowAndLevelAndTypeAndUse(String know, String level,
            String type, String srcType, String userId, Pageable pageable);

    /**
     * 根据分组查询，试题
     * 
     * @param userId
     * @param groupId
     * @param level
     * @param type
     * @return
     */
    public Page<ElasticYxyYxyQuesResource> questionFindByMyGroupId(String schoolId, String userId, String groupId,
            String level, String type, String phase, String subject, Pageable pageable);

    /**
     * 根据所选章节，取交集知识点
     * 
     * @param bookcontent
     * @param quesIdList
     * @return
     */
    public List<Integer> getBookContentKnowList(String bookcontent, List<Integer> knowList);

    /**
     * 根据知识点，取交集知识点
     * 
     * @param know
     * @param quesIdList
     * @return
     */
    public List<Integer> getKnowLedgeKnowList(String know, List<Integer> knowList);

    /**
     * 收藏试题或者取消取消收藏
     * 
     * @param userId
     * @param schoolId
     * @param quesId
     */
    public void FavQuesOrCancelQues(String userId, String schoolId, String quesId);

    /**
     * 保存试卷
     * 
     * @param reqModel
     * @param queslist
     */
    public void SavePaper(ReqModel reqModel, YxyProfile profile);

    /**
     * 生成试卷
     * 
     * @param reqModel
     * @param downloadDir
     */
    public String DownLoadPaper(DownLoadReqModel reqModel, String downloadDir) throws Exception;

}
